home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / oleo-1_4.lha / oleo-1.4 / eval.h < prev    next >
C/C++ Source or Header  |  1993-03-19  |  6KB  |  248 lines

  1. #ifndef EVALH
  2. #define EVALH
  3.  
  4. /*    Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc.
  5.  
  6. This file is part of Oleo, the GNU Spreadsheet.
  7.  
  8. Oleo is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2, or (at your option)
  11. any later version.
  12.  
  13. Oleo is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with Oleo; see the file COPYING.  If not, write to
  20. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  21.  
  22.  
  23. #include "cell.h"
  24.  
  25.  
  26. /* Despite the name, this file contains the #defines for all the byte-compiled
  27.    byte values.
  28.  */
  29.  
  30. /* 0 - 5  Control stuff */
  31. #define ENDCOMP        0    /* End of compiled code */
  32.  
  33. /* These are followed by a jump-code, or a two-byte jump-code */
  34.  
  35. #define IF        2    /* Followed by jump-code */
  36. #define IF_L        3
  37. #define F_IF        4    /* Like if, but decompiles differently */
  38. #define F_IF_L        5
  39. #define AND        6    /* Followed by jump-code */
  40. #define AND_L        7    /* Followed by jump-code */
  41. #define OR        8    /* Followed by jump-code */
  42. #define OR_L        9
  43.  
  44. #define CONST_STR    10
  45. #define CONST_STR_L    11
  46.  
  47. /* 12 - 15 Cell references */
  48. #define R_CELL        12
  49. #define ROWREL        1
  50. #define COLREL        2
  51.  
  52. /* 16 - 31 Range references */
  53. #define RANGE        16
  54. #define LRREL        1
  55. #define HRREL        2
  56. #define LCREL        4
  57. #define HCREL        8
  58.  
  59. /* 32 - 130  Various Constants */
  60. #define F_TRUE        32
  61. #define F_FALSE        33
  62. #define CONST_INF    34
  63. #define CONST_NINF    35
  64. #define CONST_NAN    36
  65. #define CONST_ERR    37    /* Followed by error code and text(?) */
  66. #define CONST_FLT    38    /* Followed by double */
  67. #define CONST_INT    39    /* Followed by long */
  68.  
  69. /* 131    Variable reference */
  70. #define VAR        40    /* Followed by struct var * */
  71.  
  72. /* Unary Functions */
  73. #define NEGATE        41
  74. #define NOT        42
  75.  
  76. /* Binary Functions */
  77. #define DIFF        43
  78. #define DIV        44
  79. #define MOD        45
  80. #define PROD        46
  81. #define SUM        47
  82. #define CONCAT        48
  83. #define EQUAL        49
  84. #define GREATEQ        50
  85. #define GREATER        51
  86. #define LESS        52
  87. #define LESSEQ        53
  88. #define NOTEQUAL    54
  89. #define POW        55
  90.  
  91. #define F_PI        56
  92. #define F_ROW        57
  93. #define F_COL        58
  94. #define F_NOW        59
  95.  
  96. /* 40 - 65 one-operand functions */
  97. #define F_ABS        60
  98. #define F_ACOS        61
  99. #define F_ASIN        62
  100. #define F_ATAN        63
  101. #define F_CEIL        64
  102. #define F_INT        65
  103. #define F_FLOOR        66
  104. #define F_COS        67
  105. #define F_DTR        68
  106. #define F_EXP        69
  107. #define F_LOG        70
  108. #define F_LOG10        71
  109. #define F_RTD        72
  110. #define F_SIN        73
  111. #define F_SQRT        74
  112. #define F_TAN        75
  113. #define F_CTIME        76
  114. #define F_NEG        77
  115. #define F_NOT        78
  116. #define F_ISERR        79
  117. #define F_ISNUM        80
  118. #define F_RND        81
  119. #define F_ROWS        82
  120. #define F_COLS        83
  121.  
  122. /* 75 - 98 Two-operand functions */
  123. #define F_ATAN2        84
  124. #define F_HYPOT        85
  125. #define F_FIXED        86
  126. #define F_IFERR        87
  127.  
  128. #define F_INDEX        88
  129.  
  130. /* 100 - 106 Three input functions */
  131. #define F_INDEX2    89
  132.  
  133. /* 110 - 114 N-input functions */
  134. #define F_ONEOF        90
  135.  
  136. #define F_FILE        91
  137.  
  138. /* 115 - 122 area functions */
  139. #define AREA_SUM    92
  140. #define AREA_PROD    93
  141. #define AREA_AVG    94
  142. #define AREA_STD    95
  143. #define AREA_MAX    96
  144. #define AREA_MIN    97
  145. #define AREA_CNT    98
  146. #define AREA_VAR    99
  147.  
  148. #define USR1        100    /* User defined function */
  149. /* Followed by function # */
  150.  
  151. #define SKIP        254
  152. #define SKIP_L        255
  153.  
  154. struct function
  155.   {
  156.     /* See C_mumble below.  This is used when byte-compiling,
  157.             and decompiling */
  158.     /* The infix information is *not* used for parsing, although
  159.            it should be. . . */
  160.     short fn_comptype;
  161.  
  162.     /* See X_mumble below.  This encodes the number of arguments
  163.            this function takes.  It is used by the expression
  164.            evaluator and the parser. */
  165.     char fn_argn;
  166.  
  167.     /* This is used by the expression evaluator to convert the
  168.             args to the fun into the appropriate type
  169.             (And by the parser to see if the function will accept
  170.            regions as arguments) */
  171.     char fn_argt[5];
  172.  
  173.     /* This function is called by the expression evaluator
  174.             when the (spreadsheet) function is executed */
  175.     void (*fn_fun) ();
  176.  
  177.     /* This is the function's name.  It gets used for compiling
  178.            decompiling, and parsing. . . */
  179.     char *fn_str;
  180.   };
  181.  
  182. extern struct function the_funs[];
  183. extern int n_usr_funs;
  184. extern struct function **usr_funs;
  185. extern int *usr_n_funs;
  186. extern struct function skip_funs[];
  187.  
  188. /* Magic numbers for byte-compiling and decompiling expressions */
  189. /* These need only be distinct (and have x|C_T be distinct too!) */
  190. #define GET_COMP(x) ((x)&0x1f)
  191. #define C_IF     0x1
  192. #define C_ANDOR  0x2
  193. #define C_ERR     0x3
  194. #define C_FLT     0x4
  195. #define C_INT     0x5
  196. #define C_STR     0x6
  197. #define C_VAR     0x7
  198. #define C_CELL     0x8
  199. #define C_RANGE     0x9
  200. #define C_FN0X     0xA
  201. #define C_FN0     0xB
  202. #define C_FN1     0xC
  203. #define C_FN2     0xD
  204. #define C_FN3     0xE
  205. #define C_FN4     0xF
  206. #define C_FNN    0x10
  207. #define C_INF    0x11
  208. #define C_UNA    0x12
  209. #define C_CONST    0x13
  210. #define C_SKIP  0x14
  211.  
  212. #define C_T     0x20
  213.  
  214. #define INF(x)    (x<<8)
  215. #define ASO    0xC0
  216. #define R    0x40
  217. #define L    0x80
  218. #define N    0xC0
  219.  
  220. #define ISINFIX(x)    ((x)&ASO)
  221. #define GET_IN(x)    ((x)>>8)
  222. #define GET_ASO(x)    (((x)&ASO)==R ? -1 : (((x)&ASO)==L ? 1 : 0))
  223.  
  224. #define X_ARGS    0x07
  225. #define X_A0    0
  226. #define X_A1    1
  227. #define X_A2    2
  228. #define X_A3    3
  229. #define X_A4    4
  230. #define X_AN    5
  231.  
  232. #define X_J    0x08
  233. #define X_JL    0x10
  234.  
  235. #ifdef __STDC__
  236. extern void update_cell (CELL *);
  237. extern double rtd (double);
  238. extern double dtr (double);
  239. extern double to_int (double);
  240. #else
  241. extern void update_cell ();
  242. extern double rtd ();
  243. extern double dtr ();
  244. extern double to_int ();
  245. #endif
  246.  
  247. #endif
  248.